Skip to content

[doc] Usecases with docbase as param #1502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 6, 2016

Conversation

felixmulder
Copy link
Contributor

@felixmulder felixmulder commented Sep 8, 2016

Cherry-picked the commit from @odersky's branch on inline that refactors Attachment.Key[A] => Property.Key[A] and implemented the docbase as a property - which will then cause the typechecking of usecases only when the docbase property is present in the context.

Other than that, not much has changed from #1472

Review: @odersky

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good, but I would like to see better decoupling between core compiler and dottydoc.


class ExpansionLimitExceeded(str: String) extends Exception
}
}
Copy link
Contributor

@odersky odersky Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why put this in core instead of dottydoc? A lot of the logic seems to be doc-specific. Proposal: Keep Comment as a pure data class as it was in Scanners. Implement the new logic as methods external to Comment. Comment contains only defs (the only val in it could as well be a def), so this is easy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odersky: I think the basis of this review rests on the thoughts in this comment, as such let me try to address these concerns here in summary.

My reasons for keeping this in the compiler is for tooling - I think that's the same reason as to why this implementation was in nsc and not in Scaladoc for scalac.

When we have a presentation compiler - we're going to want expanded (or "cooked") comments for the standard library entities.

The Comment in core as such - does not deal with things that dottydoc does - like @group and other dottydoc specific annotations - it only deals with expansion of definitions and the comment inheritance.

@@ -68,6 +69,9 @@ object Contexts {
/** The context base at the root */
val base: ContextBase

/** Documentation base */
def getDocbase = property(DocContext)
Copy link
Contributor

@odersky odersky Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this out of Context? The design should be ideally one of a plugin. That is, there is a context property, but the Contexts object knows nothing about it. I would do it more like we model defn: Put in the main Doc object:

 val DocBase = ...
 def getDocBase(implicit ctx: Context) = ctx.property(DocBase)

@@ -573,10 +578,15 @@ object Contexts {
}
}

val DocContext = new Key[DocBase]
class DocBase {
Copy link
Contributor

@odersky odersky Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DocContext should be renamed to DocBase for consistency.
Both kinds of DocBase should also move to the dottydoc package, I think.

@@ -1515,7 +1515,9 @@ object SymDenotations {

/** Enter a symbol in given `scope` without potentially replacing the old copy. */
def enterNoReplace(sym: Symbol, scope: MutableScope)(implicit ctx: Context): Unit = {
require((sym.denot.flagsUNSAFE is Private) || !(this is Frozen) || (scope ne this.unforcedDecls) || sym.hasAnnotation(defn.ScalaStaticAnnot))
def isUsecase = ctx.property(DocContext).isDefined && sym.name.show.takeRight(4) == "$doc"
Copy link
Contributor

@odersky odersky Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this line to a "isUserCase" method in the dottydoc package.

@@ -1456,6 +1462,45 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
traverse(stats)
}

private def typedUsecases(syms: List[Symbol], owner: Symbol)(implicit ctx: Context): Unit =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think expandParentDocs belongs in DottyDoc, not in Typer. So I would move typedUseCases there as well. Pass the typer as a paremeter, so it can call back to enterSymbol, createSymbol, typedStats.

import scala.reflect.internal.Chars._

object CommentUtils {
object CommentParsing {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a comment what it does.

Also what's the motivation for keeping this in util? Is it used outside dottydoc as well?

@felixmulder felixmulder force-pushed the topic/dottydoc-usecases-param branch from e4e19e0 to b3d2b2c Compare September 21, 2016 13:02
doc.map(d => _docstrings += (sym -> d))
}

abstract case class Comment(pos: Position, raw: String)(implicit ctx: Context) { self =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a context into a class always poses the risk of space leaks. It's better not to make the context implicit, so that we can track precisely where it is used. It's even better not to pass a context into a class at all.

@felixmulder felixmulder force-pushed the topic/dottydoc-usecases-param branch from b3d2b2c to 86c9209 Compare October 5, 2016 08:06
@odersky
Copy link
Contributor

odersky commented Oct 6, 2016

LGTM!

@felixmulder felixmulder force-pushed the topic/dottydoc-usecases-param branch from 86c9209 to 9bcf282 Compare October 6, 2016 16:26
@felixmulder felixmulder merged commit 0426fe7 into scala:master Oct 6, 2016
odersky added a commit to dotty-staging/dotty that referenced this pull request Oct 13, 2016
Fixes scala#1502 by making the length field use 1 or 2 bytes,
depending on the number of parameters in a signature.
odersky added a commit to dotty-staging/dotty that referenced this pull request Oct 13, 2016
Fixes scala#1502 by making the length field use 1 or 2 bytes,
depending on the number of parameters in a signature.
odersky referenced this pull request Oct 16, 2016
Fix #1544: Allow long signatures in names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants